home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Libraries / CModalProgress / CModalProgress.h < prev    next >
Encoding:
Text File  |  1994-09-01  |  3.8 KB  |  121 lines  |  [TEXT/MMCC]

  1. // ===========================================================================
  2. //    ModalProgress.h
  3. //    
  4. //    This file contains the header information for the ModalProgress class.
  5. //    This class provides an interface for displaying to the user, a visual 
  6. //    indication to the progress of a time intensive task. 
  7. //
  8. //    The resource ID of a dialog resource is passed to the constructor which
  9. //    will be used in the progress dialog. There are a number of things to
  10. //    consider when creating the dialog as certain items must be present for
  11. //    some actions to take place.
  12. //
  13. //    If an OK equivalent button is needed, then use item 1 for this purpose.
  14. //    If you wish this button to have a border, create a user item the size of
  15. //    the outline, place it over the OK button, this should be item 3.
  16. //
  17. //    A CANCEL button should use item number 2, if required.
  18. //
  19. //    Standard key equvalents are supported, Enter, Return, Command-., ESC for
  20. //    each of these buttons.
  21. //
  22. //    If these particular items are not required by the dialog, they must be
  23. //    generated as hidden disabled items. Do not just leave the items out of
  24. //    the diaog.
  25. //
  26. //
  27. //    If a progress bar is required in the dialog (which is expected for most
  28. //    uses of this class) it should be generated as a user item that is the
  29. //    size of the frame that is required for this bar. The item number of this
  30. //    user item is passed to the SetProgressBar or SetInfiniteBar method.
  31. //    
  32. //    If a simple text value of percent complete is required, the item should
  33. //    be generated as a StaticText item, and its item number passed to the
  34. //    SetPercentText method along with the resolution of update.
  35. //
  36. //
  37. //    History
  38. //    -------
  39. //    
  40. //    01/09/94        G. Heathcote    Created Version 1.0.
  41. //    
  42. //    Version 1.0
  43. //
  44. //    Copyright 1994 Alysoft Solutions. All rights reserved.
  45. //
  46. // ===========================================================================
  47.  
  48. #pragma once
  49.  
  50. typedef enum {
  51.     kDialogContinues                            = 0,
  52.     kDialogOKHit,
  53.     kDialogCancelHit,
  54.     kDialogExceeding100pc,
  55.  
  56.     kStateSpaceWithinLimit,
  57.     kStateSpaceExceedingLimit
  58. } tDialogProcessStates ;
  59.  
  60. typedef enum {
  61.     kDefaultButtonIndex                            = 1,
  62.     kCancelButtonIndex,
  63.     kDefaultButtonOutlineIndex
  64. } tDialogItemIndicies ;
  65.  
  66. #define    kIndicatorOutline                        0x0001
  67. #define    kIndicatorContent                        0x0002
  68.  
  69. #define    kDefaultInfiniteDrawDelay                1
  70. #define    kInfinitePaternResID                    6000
  71.  
  72. class CModalProgress
  73. {
  74.     private:
  75.         float                    fStartStatePercent ;
  76.         float                    fCurrentStateSpace ;
  77.         float                    fCurrentStateValue ;
  78.         float                    fCurrentStateSpacePercent ;
  79.         long                    fInfiniteDrawTime ;
  80.         Boolean                    fPercentText ;
  81.         Boolean                    fProgressBar ;
  82.         Boolean                    fInfiniteBar ;
  83.         short                    fPercentTextItem ;
  84.         short                    fProgressBarItem ;
  85.         short                    fInfiniteBarItem ;
  86.         short                    fPercentTextDeltaLimit ;
  87.  
  88.         Boolean            FlashButton(DialogPtr theDialog, short buttonIndex) ;
  89.         void            UpdateProgressIndicator(float newPercent) ;
  90.  
  91.     protected:
  92.         virtual short    ProcessEvent(EventRecord *theEvent) ;
  93.         virtual    void    DrawPercentIndicator(float percent, short deltaLimit, short itemIndex, short part) ;
  94.         virtual    void    DrawStdBarIndicator(float percent, short itemIndex, short part) ;
  95.         virtual    void    DrawInfiniteBarIndicator(float percent, short itemIndex, short part) ;
  96.  
  97.     public:
  98.         DialogPtr                fDialog ;
  99.         float                    fCurrentPercent ;
  100.         long                    fInfiniteDrawDelay ;
  101.  
  102.         CModalProgress() ;                            // Constructor
  103.         ~CModalProgress() ;                            // Destructor
  104.  
  105.         virtual    short    SetupDialog(short dlgResId) ;
  106.         virtual    void    SetProgressBar(short dlgItem) ;
  107.         virtual    void    SetInfiniteBar(short dlgItem) ;
  108.         virtual    void    SetPercentText(short dlgItem, short deltaLimit) ;
  109.         
  110.         virtual    void    SetCurrentState(float statePercent) ;
  111.         virtual    void    SetStateSpace(float space) ;
  112.         virtual short    SetCurrentStateValue(float value) ;
  113.  
  114.         virtual    void    DrawProgressIndicator(float percent, short part) ;
  115.         
  116.         virtual    void    BeginModal(void) ;
  117.         virtual    short    ProcessModal(void) ;
  118.         virtual    void    EndModal(void) ;
  119.  
  120. } ;
  121.